<?php
/**
 * @copyright	Copyright (C) 2008 Bideew. All rights reserved.
 * @license		GNU/GPL
* This file is part of Bideew.

* Bideew is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.

* Bideew is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.

* You should have received a copy of the GNU General Public License
* along with Bideew; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
// Pas d'acces direct 
defined('fADMIN') or die( 'Restricted access' );

require("functions.php");
require("functions.js.php");

if(isset($_POST['MODEEDITEUR']))
{
	$modeEditeur=$_POST['MODEEDITEUR'];
}
else
{
	$modeEditeur=NULL;
}

if(isset($_POST['modification_fichier']))
{
	$fichier=fopen($_POST['CHEMIN'],'w');
	fwrite($fichier,$_POST['modification_fichier']);
	fclose($fichier);
}

if(isset($_POST['CHEMIN']))
		{
			$fichier=fopen($_POST['CHEMIN'],'r');
			$contenuFichier=NULL;
			while(!feof($fichier))
			{
				$contenuFichier.=fgets($fichier);
			}
			fclose($fichier);
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   

<html>
   <head>
      	<title>tiny MCE</title>
   </head>
  <body>
<script type="text/javascript" src="scripts/jscripts/tiny_mce/tiny_mce.js"></script>	
<script type="text/javascript">			
		tinyMceModeOuverture(<?php echo $modeEditeur;?>);
</script>	


	<form  action="<?php echo $URL; ?>&amp;send=true" method="post">
		<p><input type="hidden" name="CHEMIN" value="<?php echo $_POST['CHEMIN']; ?>" />
		<p><input type="hidden" name="MODEEDITEUR" value="<?php echo $modeEditeur; ?>" />
		<textarea name="modification_fichier" cols="100" rows="30"><?php echo $contenuFichier;?></textarea></p>
		<p><input type="submit" value="modifier" /></p>
	</form>
	
</body>
</html>
<?php
}
?>

<h1>Editer un fichier</h1>
<br/><br/>

<?php
 if(isset($_GET['path']))
 {
	$path=$_GET['path'];
 }
 else
 {
	$path=PATHTOROOT;
 }
 
 GetListDossiers($path);
?>
</fieldset>